package com.example.demo.controller;

import com.example.demo.model.RandomValues;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import lombok.extern.slf4j.Slf4j;

/**
 * Created by weishaofei on 2018/12/20.
 */
@RestController
@Slf4j
public class TestController {

    @Autowired
    private RandomValues randomValues;

    @Autowired
    private DiscoveryClient discoveryClient;


    @RequestMapping("/test")
    public String getName() {
        ServiceInstance serviceInstance = discoveryClient.getLocalServiceInstance();

        log.info("host: " + serviceInstance.getHost() + ", service_id: " + serviceInstance.getServiceId());
        randomValues.show();
        return "test ok";
    }
}
